package com.xiangyueEducation.uploaderCloud.config;

import com.xiangyueEducation.uploaderCloud.utils.enums.PathEnum;
//import com.xiangyueEducation.uploaderCloud.interceptor.CheckRoleInterceptor;
import com.xiangyueEducation.uploaderCloud.utils.enums.PathEnum;
import com.xiangyueEducation.uploaderCloud.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;



@Configuration
public class MySpringMVCConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // 拦截器一定要加上顺序，先登录再看你是什么身份
//        registry.addInterceptor(loginInterceptor)
//                .excludePathPatterns("/account/**")
//                .excludePathPatterns("/common/**");
//    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img/avatar/**").addResourceLocations("classpath:"+ PathEnum.AVATAR.getPath());
    }
}
